package com.lanou3g.dllo.baidumusic.musiclibrary;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by dllo on 16/6/17.
 */
public class MusicLibraryAdapter extends FragmentPagerAdapter {

    private ArrayList<Fragment> datas;
    private String[] titles = {"推荐", "排行", "歌单", "电台", "MV"};

    public MusicLibraryAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setDatas(ArrayList<Fragment> datas) {
        this.datas = datas;
    }

    @Override
    public Fragment getItem(int position) {
        return datas.size() > 0 && datas != null ? datas.get(position) : null;
    }

    @Override
    public int getCount() {
        return datas.size() > 0 && datas != null ? datas.size() : 0;
    }

    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

}
